def numsplit_sum(num):
    num *= 10
    s = [(num % (10 ** (i + 1))) // (10 ** i) for i in range(1, len(str(num)))]
    return sum(s)


if __name__ == '__main__':
    max = 1
    for a in range(1, 100):
        for b in range(1, 100):
            t = numsplit_sum(a ** b)
            if max < t:
                max = t
    print(max)
